package com.t.bricks.bussiness.db.dao.document.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import com.t.bricks.bussiness.db.dao.document.DocumentDao;
import com.t.bricks.bussiness.db.entity.document.Document;
import com.t.bricks.bussiness.db.mapper.document.DocumentMapper;
import com.t.bricks.model.Log;
import com.t.bricks.model.MsgEmity;

@Repository
public class DocumentDaoImpl implements DocumentDao<Document> {
	
	@Autowired
	private DocumentMapper documentMapper;

	/**
	 * 根据编号和分享值获取文件路径
	 * @param sId 记录编号
	 * @param sSharesKey 分享码(在非共享下可通过此分享码查看)
	 * @return
	 */
	@Override
	public MsgEmity getFilePath(String sId, String sSharesKey) {
		String sFilePath = null;
		try {
			sFilePath = documentMapper.getFilePath(sId, sSharesKey);
			if (null == sFilePath) {
				return new MsgEmity(false, "数据不存在！", 7001);
			}
		} catch (Exception e) {
			Log.error("查询发生异常:", e.getMessage());
			return new MsgEmity(false, "查询失败！", 7002);
		}
		
		return new MsgEmity(true, "查询成功！", sFilePath);
	}
	
}
